package domain;

import java.util.Collection;
import java.util.Date;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

@Entity
@Access(AccessType.PROPERTY)
public class Event extends DomainEntity {

	private String referenceNumber;

	private String title;

	private double fee;

	private String description;

	private Date creationMoment;

	private Date startMoment;

	private Date finishMoment;

	private Double rating;

	@NotBlank
	public String getReferenceNumber() {
		return referenceNumber;
	}

	public void setReferenceNumber(String referenceNumber) {
		this.referenceNumber = referenceNumber;
	}

	@NotBlank
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public double getFee() {
		return fee;
	}

	public void setFee(double fee) {
		this.fee = fee;
	}

	@NotBlank
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Date getCreationMoment() {
		return creationMoment;
	}

	public void setCreationMoment(Date creationMoment) {
		this.creationMoment = creationMoment;
	}

	public Date getStartMoment() {
		return startMoment;
	}

	public void setStartMoment(Date startMoment) {
		this.startMoment = startMoment;
	}

	public Date getFinishMoment() {
		return finishMoment;
	}

	public void setFinishMoment(Date finishMoment) {
		this.finishMoment = finishMoment;
	}

	public Double getRating() {
		return rating;
	}

	public void setRating(Double rating) {
		this.rating = rating;
	}

	// Relationships ----------------------------------------------------------
	private Administrator administrator;

	private Collection<Route> route;

	private Collection<Registration> registration;

	private Collection<Challenge> challenge;

	@Valid
	@NotNull
	@ManyToOne(optional = false)
	public Administrator getAdministrator() {
		return administrator;
	}

	public void setAdministrator(Administrator administrator) {
		this.administrator = administrator;
	}

	@Valid
	@NotNull
	@OneToMany(cascade=CascadeType.ALL,mappedBy="event")
	public Collection<Route> getRoute() {
		return route;
	}

	public void setRoute(Collection<Route> route) {
		this.route = route;
	}

	@Valid
	@NotNull
	@OneToMany(mappedBy = "registration")
	public Collection<Registration> getRegistration() {
		return registration;
	}

	public void setRegistration(Collection<Registration> registration) {
		this.registration = registration;
	}

	@Valid
	@NotNull
	@OneToMany(cascade=CascadeType.ALL,mappedBy="event")
	public Collection<Challenge> getChallenge() {
		return challenge;
	}

	public void setChallenge(Collection<Challenge> challenge) {
		this.challenge = challenge;
	}

}
